import request from '@/utils/request'
import { Course, CourseQuery } from './type'
//项目用户相关的请求地址
const baseUrl = '/course'

export const reqPageCourse = (
  pageNum: number,
  pageSize: number,
  queryParams: CourseQuery,
) =>
  request.post<any, TableResponse<Array<Course>>>(`${baseUrl}/page`, {
    pageSize,
    pageNum,
    ...queryParams,
  })

export const reqDeleteCourse = (ids: string[] | string) =>
  request.delete<any, ResponseData>(`${baseUrl}/${ids}`)

export const reqCourseAndDescriptionByCourseId = (courseId: string) =>
  request.get<any, ResponseData>(`${baseUrl}/${courseId}`)

export const reqAddCourseInfo = (course: Course) =>
  request.post<any, ResponseData>(`${baseUrl}/addCourseInfo`, course)

export const reqUpdateCourseInfo = (course: Course) =>
  request.put<any, ResponseData>(`${baseUrl}/updateCourseInfo`, course)

export const reqPublishCourse = (courseId: string, status: string) =>
  request.get<any, ResponseData>(`${baseUrl}/publish`, {
    params: {
      courseId,
      status,
    },
  })
